package com.example.work4.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.example.work4.adapter.viewHolder.CommentViewHolder
import com.example.work4.po.Comment

abstract class CaseAdapter<T>(var data: ArrayList<T> = ArrayList()) :RecyclerView.Adapter<CommentViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CommentViewHolder {
        return CommentViewHolder(DataBindingUtil.inflate(LayoutInflater.from(parent?.context), viewType, parent, false),0,
            Comment()
        )
    }


    override fun getItemCount(): Int {
        return data.size
    }

    @SuppressLint("NotifyDataSetChanged")
    fun refreshData(newData: ArrayList<T>) {
        this.data = newData
        this.notifyDataSetChanged()
    }
}
